1
|
|
|
import {MigrationInterface, QueryRunner} from "typeorm"; |
2
|
|
|
|
3
|
|
|
export class Quote1586264030581 implements MigrationInterface { |
4
|
|
|
name = 'Quote1586264030581' |
5
|
|
|
|
6
|
|
|
public async up(queryRunner: QueryRunner): Promise<any> { |
7
|
|
|
await queryRunner.query(`CREATE TABLE "quote" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "status" character varying NOT NULL, "quoteId" character varying NOT NULL, "date" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, "expiryDate" TIMESTAMP NOT NULL DEFAULT now(), "ownerId" uuid NOT NULL, "customerId" uuid NOT NULL, "projectId" uuid, CONSTRAINT "UQ_88778de0e0cd0f6aa68759539a9" UNIQUE ("quoteId"), CONSTRAINT "PK_b772d4cb09e587c8c72a78d2439" PRIMARY KEY ("id"))`, undefined); |
8
|
|
|
await queryRunner.query(`CREATE TABLE "quote_item" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "quantity" integer NOT NULL, "dailyRate" integer NOT NULL, "vat" integer NOT NULL, "quoteId" uuid NOT NULL, "taskId" uuid NOT NULL, CONSTRAINT "PK_a491f996b20f4b5110ec480e6bc" PRIMARY KEY ("id"))`, undefined); |
9
|
|
|
await queryRunner.query(`ALTER TABLE "quote" ADD CONSTRAINT "FK_d0a82ae7e4d8ba9e9b7337d3982" FOREIGN KEY ("ownerId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined); |
10
|
|
|
await queryRunner.query(`ALTER TABLE "quote" ADD CONSTRAINT "FK_588da10cc115a4d5c4af2955062" FOREIGN KEY ("customerId") REFERENCES "customer"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined); |
11
|
|
|
await queryRunner.query(`ALTER TABLE "quote" ADD CONSTRAINT "FK_acd0da7cbdbc23c5a47318202a7" FOREIGN KEY ("projectId") REFERENCES "project"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined); |
12
|
|
|
await queryRunner.query(`ALTER TABLE "quote_item" ADD CONSTRAINT "FK_6296266787152fd91f74cb9d1d1" FOREIGN KEY ("quoteId") REFERENCES "quote"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined); |
13
|
|
|
await queryRunner.query(`ALTER TABLE "quote_item" ADD CONSTRAINT "FK_8c958c2b27ebe521f51f1a7f317" FOREIGN KEY ("taskId") REFERENCES "quote"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, undefined); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
public async down(queryRunner: QueryRunner): Promise<any> { |
17
|
|
|
await queryRunner.query(`ALTER TABLE "quote_item" DROP CONSTRAINT "FK_8c958c2b27ebe521f51f1a7f317"`, undefined); |
18
|
|
|
await queryRunner.query(`ALTER TABLE "quote_item" DROP CONSTRAINT "FK_6296266787152fd91f74cb9d1d1"`, undefined); |
19
|
|
|
await queryRunner.query(`ALTER TABLE "quote" DROP CONSTRAINT "FK_acd0da7cbdbc23c5a47318202a7"`, undefined); |
20
|
|
|
await queryRunner.query(`ALTER TABLE "quote" DROP CONSTRAINT "FK_588da10cc115a4d5c4af2955062"`, undefined); |
21
|
|
|
await queryRunner.query(`ALTER TABLE "quote" DROP CONSTRAINT "FK_d0a82ae7e4d8ba9e9b7337d3982"`, undefined); |
22
|
|
|
await queryRunner.query(`DROP TABLE "quote_item"`, undefined); |
23
|
|
|
await queryRunner.query(`DROP TABLE "quote"`, undefined); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
} |
27
|
|
|
|